package soar.template.springboot.batch.reward.batch;

import org.springframework.batch.core.Job;
import org.springframework.batch.core.JobExecutionListener;
import org.springframework.batch.core.Step;
import org.springframework.batch.core.configuration.annotation.EnableBatchProcessing;
import org.springframework.batch.core.configuration.annotation.JobBuilderFactory;
import org.springframework.batch.core.configuration.annotation.StepBuilderFactory;
import org.springframework.batch.core.launch.support.RunIdIncrementer;
import org.springframework.batch.item.ItemProcessor;
import org.springframework.batch.item.ItemReader;
import org.springframework.batch.item.ItemWriter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableBatchProcessing
public class Batch
{
    @Bean
    public ItemReader<Person> reader()
    {
        return null;
    }

    @Bean
    public ItemProcessor<Person, Person> processor()
    {
        return null;
    }

    @Bean
    public ItemWriter<Person> writer()
    {
        return null;
    }

    @Bean
    public Job importUserJob(JobBuilderFactory jobBuilderFactory, Step s1,
            JobExecutionListener listener)
    {
        return jobBuilderFactory.get("importUserJob")
                .incrementer(new RunIdIncrementer()).listener(listener).flow(s1)
                .end().build();
    }

    @Bean
    public Step step1(StepBuilderFactory stepBuilderFactory,
            ItemReader<Person> reader, ItemWriter<Person> writer,
            ItemProcessor<Person, Person> processor)
    {
        return stepBuilderFactory.get("step1").<Person, Person> chunk(10)
                .reader(reader).processor(processor).writer(writer).build();
    }
}
